#!/bin/bash
#配置yum源
sh yum.sh
 
# 关闭防火墙
systemctl disable --now firewalld

# 关闭SELinux
sed -ri 's/(SELINUX=)enforcing/\1disabled/' /etc/selinux/config
grep ^SELINUX= /etc/selinux/config
setenforce 0
getenforce

# 安装Python3
yum -y install python3

# 安装pip
python get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple

# 安装pipx
python3 -m pip install --user pipx -i https://pypi.tuna.tsinghua.edu.cn/simple
python3 -m pipx ensurepath 

# 安装Ansible
python3 -m pip install --user ansible -i https://pypi.tuna.tsinghua.edu.cn/simple

# 添加命令补全
activate-global-python-argcomplete

# 使环境变量生效
source ~/.bashrc

#创建管理目录
mkdir -p /etc/ansible

# 配置ansible.cfg
ansible-config init --disabled > /etc/ansible/ansible.cfg

#创建主机清单
touch /etc/ansible/hosts

#创建roles
mkdir -p /etc/ansible/roles

#创建playbooks
mkdir -p /etc/ansible/playbooks

# 确认安装
ansible --version
